//
//  WTPersonToolView.m
//  WTPlayDemo
//
//  Created by ben on 16/7/26.
//  Copyright © 2016年 ben. All rights reserved.
//

#import "WTPersonToolView.h"
#import "WTCategories.h"
#import "Masonry.h"

@implementation WTPersonToolView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup{
    
    self.privateChatButton = ({
        
        UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"私信" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor hexChangeFloat:@"323232"] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:button];
        button;
    });
    
    self.attentionButton = ({
        
        UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"关注" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor hexChangeFloat:@"323232"] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:button];
        button;
    });
    
    self.topLine = ({
        
        UIView* view = [[UIView alloc] init];
        view.backgroundColor = [UIColor hexChangeFloat:@"323232"];
        [self addSubview:view];
        view;
    });
    
    self.midLine = ({
        
        UIView* view = [[UIView alloc] init];
        view.backgroundColor = [UIColor hexChangeFloat:@"323232"];
        [self addSubview:view];
        view;
    });
    
    [self layout];
}

- (void)layout{

    [self.privateChatButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.and.top.and.bottom.mas_equalTo(0);
        make.width.mas_equalTo(([UIScreen screenWidth] - 30)/2);
    }];
    
    [self.attentionButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.bottom.mas_equalTo(0);
        make.width.mas_equalTo(self.privateChatButton.mas_width);
        make.leading.mas_equalTo(self.privateChatButton.mas_trailing);
    }];
    
    [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.and.trailing.and.top.mas_equalTo(0);
        make.height.mas_equalTo(1/[UIScreen mainScreen].scale);
    }];
    
    [self.midLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.and.top.mas_equalTo(0);
        make.leading.mas_equalTo([UIScreen screenWidth]/2);
        make.width.mas_equalTo(1/[UIScreen mainScreen].scale);
    }];
}


- (void)buttonPressed:(id)sender{
    
    if(sender == self.privateChatButton){
        if(self.block){
            self.block(0);
        }
    }else {
        if(self.block){
            self.block(1);
        }
    }
    
}


@end
